<template>
	<!-- 我的评价 -->
	<div style="width: 100%;">
		<Header></Header>
		<div style="width:1200px;margin:auto; margin-top: 30px;">
			<el-table :data="comments" style="width: 100%">
				<el-table-column label="序号" width="100">
					<template #default="scope">
						{{scope.$index+1}}
					</template>
				</el-table-column>
				<el-table-column label="商品" width="250">
					<template #default="scope">
						<img :src="'http://localhost:8080/' + scope.row.imgs" style="width: 120px;height:80px;" />
					</template>
				</el-table-column>
				<el-table-column label="商品名称" width="150" prop='goodsname'>
				</el-table-column>
				<el-table-column label="分数" width="150" prop='fs'>
				</el-table-column>
				<el-table-column label="评价内容" width="150" prop='content'>
				</el-table-column>
				<el-table-column label="时间" width="150" >
					<template #default="scope">
							{{formatTime(scope.row.ctime)}}
					</template>
				</el-table-column>
				<!-- <el-table-column label="商品" width="250">
				<template #default="scope">
					<el-button size="small" type='daner' @click="deleteSupplier(scope.row,scope.$index)">删除
					</el-button>
				</template>
			</el-table-column> -->
			</el-table>
		</div>
	</div>
</template>

<script>
	import Axios from 'axios'
	import {
		ElMessageBox,
		ElMessage
	} from 'element-plus'
	import router from "../route/index.js"
	import Header from './Header'
	export default {
		name: 'MyComments',
		components: {
			Header
		},
		data() {
			return {
				comments: []
			}
		},
		created() {
			this.getUsers();
			this.getComments();
		},
		methods: {
			formatTime(val) {
				return val.substr(0, 10)
			},
			getUsers() {
				// 获取sessionstorage中的用户信息
				let str = sessionStorage.getItem('users')
				if (str != null) {
					this.show = true; //欢迎可见
					//把字符串转换成对象 --- sessionStorage存的必须时字符串，所以取出来的也是字符串
					this.users = JSON.parse(str);
				}
			},
			getComments() {
				Axios.post('/shopmng/api/comments/selectMyComments', {
					'uid': this.users.uid
				}).then(res => {
					this.comments = res.data;
				});
			},
			deleteSupplier() {

			}
		}
	}
</script>

<style>
</style>
